package cn.zzdt4j.console.controller;

import cn.zzdt4j.common.constant.Constants;
import cn.zzdt4j.common.model.Result;
import cn.zzdt4j.console.model.ChartInfo;
import cn.zzdt4j.console.model.LineChartInfo;
import cn.zzdt4j.console.model.PieChartInfo;
import cn.zzdt4j.console.model.TenantChart;
import cn.zzdt4j.console.service.DashboardService;
import cn.zzdt4j.server.common.base.Results;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * The type Dashboard controller.
 *
 * @author by <a href="mailto:ligang941012@gmail.com">gang.Li</a>
 * @since 2023 /11/6 20:16
 */
@RestController
@AllArgsConstructor
@RequestMapping(Constants.BASE_PATH + "/dashboard")
public class DashboardController {

    private final DashboardService dashboardService;

    @GetMapping
    public Result<ChartInfo> dashboard() {
        return Results.success(dashboardService.getChartInfo());
    }

    @GetMapping("/line/chart")
    public Result<LineChartInfo> lineChart() {
        LineChartInfo lineChartInfo = dashboardService.getLineChartInfo();
        return Results.success(lineChartInfo);
    }

    @GetMapping("/tenant/chart")
    public Result<TenantChart> tenantChart() {
        TenantChart tenantChart = dashboardService.getTenantChart();
        return Results.success(tenantChart);
    }

    @GetMapping("/pie/chart")
    public Result<PieChartInfo> pieChart() {
        PieChartInfo pieChartInfo = dashboardService.getPieChart();
        return Results.success(pieChartInfo);
    }
}
